<?php
namespace Home\Widget;
use Think\Controller;

/**
* 微信事件处理
*/
class EventWidget extends Controller
{
	
	public function index($data)
	{
	
	 $artid= C('WXARTID');
       $mapart['id']=array('in',$artid);
       $artarr= M('article')->where($mapart)->select();
       $art=array();
       foreach ($artarr as $key =>$vo){
       	$art[$key]=array($vo['title'],'',getImgs($vo['description'],0),(is_ssl()?'https://':'http://').$_SERVER['HTTP_HOST'].'/'.C('WEB_DIR').'/'.ZSU('/artc/'.$vo['id'],'Index/artc',array('id'=>$vo['id'])));
      
       
       	
       } 
      
		$wx = new \Common\Weixin\Weixin();
	   if ( $data['Event']['Event'] == 'subscribe' ) {
			$result = array(
                'MsgType' => 'text',
                'Content' => C('WXWELCOME')
            );
		}
		if ( $data['Event']['Event'] == 'CLICK' ) {
			if ( $data['Event']['EventKey'] == 'newblog' ) {
				
				
				
				
			
				$result = array(
						'MsgType' => 'news',
                'Content' => $art
				);
			}
		}
		
		return $wx->toWeixin($result);
	}

}